package com.itheima;

/**
 * 2025/3/29 11:38
 * 交换数组的两个元素
 */
public class ArrayPractice3 {
    public static void main(String[] args) {
        int[] arr = {10, 20, 30, 40, 50};
        /*int temp = arr[4];
        arr[4]= arr[0];
        arr[0] = temp;*/
        swap(arr,0,4);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+"\t");
        }
    }
    public static void swap(int[] arr,int i,int j){
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }

}
